﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using XamlCast.Player.ViewModels;

namespace XamlCast.Player.Views {
    public partial class PodcastEpisode : Page {
        public PodcastEpisode() {
            InitializeComponent();
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e) {
            var podcastSlug = NavigationContext.QueryString["slug"];
            if (!string.IsNullOrEmpty(podcastSlug)) {
                foreach (var pi in MainPageViewModel.CurrentMainPage.FeedItems) {
                    if (pi.Slug.EndsWith(podcastSlug, StringComparison.OrdinalIgnoreCase)) {
                        MainPageViewModel.CurrentMainPage.SelectedPodcast = pi;
                        break;
                    }
                }
            }
        }

        protected override void OnNavigatedFrom(NavigationEventArgs e) {
            base.OnNavigatedFrom(e);

        }
    }
}
